package basics.files;

import java.io.File;

import javax.swing.JFileChooser;

public class DirectoryReader {

  public static void main(String[] args) {

	  JFileChooser fc = new JFileChooser();
	  int returnVal = fc.showDialog(fc, null);
	  String Directory="c:/";
      if (returnVal == JFileChooser.APPROVE_OPTION) {
          //File file = fc.getSelectedFile();
          Directory=fc.getSelectedFile().getParent();
      }
    File folder = new File(Directory);
    File[] listOfFiles = folder.listFiles();

    for (int i = 0; i < listOfFiles.length; i++) {
      if (listOfFiles[i].isFile()) {
        System.out.println("File " + listOfFiles[i].getName());
      } else if (listOfFiles[i].isDirectory()) {
        System.out.println("Directory " + listOfFiles[i].getName());
      }
    }
  }

} 